#! /bin/sh

### BEGIN INIT INFO
# Provides:          mountGBKfs
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mountGBKfs for vsftpd on colinux
# Description:       mountGBKfs for vsftpd on colinux
### END INIT INFO

PATH=/usr/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin
DAEMON=/usr/bin/convmvfs
NAME=convmvfs
DESC=convmvfs
SRC=/mnt/cofs1
TO=/mnt/cofs1_gbk
test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
	echo -n "\033[0;33;1mStarting $DESC: \033[0m"
        $NAME $TO -o srcdir=$SRC,icharset=utf8,ocharset=gbk,allow_other,uid=0 || true
	;;
  stop)
	echo -n "\033[0;33;1mStoping $DESC: \033[0m "
	fusermount -u $TO || true
	;;
  restart|force-reload)
	echo -n "\033[0;33;1mRestarting $DESC: \033[0m"
        fusermount -u $TO || true
	sleep 1
        $NAME $TO -o srcdir=$SRC,icharset=utf8,ocharset=gbk,allow_other,uid=0 || true
	;;
  *)
	echo "Usage: $NAME {start|stop|restart}" >&2
	exit 1
	;;
esac

exit 0
